﻿import QQMapWX from '@/assets/lib/qqmap-wx-jssdk.js';
let qqmapsdk;
qqmapsdk = new QQMapWX({
  key: 'B5FBZ-R47CP-VLTD7-LPMVC-7AGAF-LOBJ4'
});

/**
 * @desc 获取地址信息
 */
export function getLocation() {
  return new Promise((resolve, reject) => {
    if (navigator.geolocation) {
      console.log("navigator.geolocation", navigator.geolocation.getCurrentPosition(function (data) {
        console.log("data", data)
      }))
      navigator.geolocation.getCurrentPosition(function (position) {
        console.log("hahahhahahah", position)

      }, err => {
        console.log("err", err)
      })
    }
  })
}
/**
 * @desc 当前是否是wifi状态
 */
export function isWifi() {
  try {
    let wifi = true
    let ua = window.navigator.userAgent
    let con = window.navigator.connection
    // 如果是微信
    if (/MicroMessenger/.test(ua)) {
      if (ua.indexOf('WIFI') >= 0) {
        return true;
      } else {
        wifi = false
      }
      // 如果支持navigator.connection
    } else if (con) {
      let network = con.type
      if (network !== 'wifi' && network !== '2' && network !== 'unknown') {
        wifi = false
      }
    }
    return wifi
  } catch (e) {
    return false
  }
}
